package com.smartcommunity.service.village;

import com.smartcommunity.bean.model.Pager;
import com.smartcommunity.bean.model.Result;
import com.smartcommunity.bean.entity.Village;
import com.smartcommunity.bean.entity.VillageEntranceExit;
import com.smartcommunity.entity.Unit.Unit;
import com.smartcommunity.entity.Unit.UnitSearch;
import com.smartcommunity.entity.statistic.StatisticsVillageDataResp;
import com.smartcommunity.entity.village.*;
import com.smartcommunity.entity.village.dto.VillageForPeopleManage;

import java.sql.SQLException;
import java.util.List;
import java.util.Map;
import java.util.Set;

/**
 * @Description: 小区相关接口
 * @author: zdy
 * @version V2.0.1
 */
public interface VillageService {

    /**
     * 通过小区编号和楼栋编号获取楼栋信息
     *
     * @param build
     * @return
     */
    Pager<Building> pageBuildings(Building build);

    /**
     * 通过小区编号和楼栋编号获取楼栋里的房屋信息
     *
     * @param house
     * @return
     */
    List<Map<String,Object>> listHousesByBuilding(House house);


    /**
     * 通过小区编号和身份证获取楼栋里的房屋信息
     * @param map
     * @return
     */
    List<Map<String,Object>> listHouses(Map<String, String> map);

    /**
     * 通过小区编号查询小区出入口信息
     * @param map
     * @return
     */
    List<Map<String,Object>> listVillageEntranceExits(Map<String, String> map);

    /**
     * 通过小区编号查询小区信息
     * @param map
     * @return
     */
    List<Map<String,Object>> listVillagesByVillageCode(Map<String, Object> map);

    /**
     * 通过小区编号和楼栋编号获取楼栋里的房屋列表信息
     * @param
     * @return
     */
	Pager<House> pageHousesByBuilding( House house);

    /**
     * 查询房屋编号
     * @param map
     * @param pageNumber
     * @param pageSize
     * @return
     */
    Pager<House> pageHouseNos(Map<String, String> map, int pageNumber, int pageSize);

    /**
     * 查询楼栋编号
     * @param map
     * @param pageNumber
     * @param pageSize
     * @return
     */
    Pager<House> pageBuildingNos(Map<String, String> map, int pageNumber, int pageSize);
    /**
     * 获取小区最高层组织机构ID
     *
     * @return
     */
    List<OrganizationVillage> OrganizationVillageOneID();

    OrganizationVillage getOrganization(Map<String, Object> param);


    /**
     * 获取小区基本信息ALL
     * @param param 请求参数，包括当前用户的数据权限小区集
     * @return
     */
    List<Village> getAllVillage(Map<String, Object> param);

    /**
     * 新增小区机构
     */
    Result insertVillageOrg(OrganizationVillage bean);
    /**
     * 更新小区机构
     */
    Result updateVillageOrg(OrganizationVillage bean);
    /**
     * 删除小区机构
     */
    Result deleteVillageOrg(String id);

    /**
     * 新增小区
     */
    Result insertVillage(Village bean);
    /**
     * 更新小区
     */
    Result updateVillage(Village bean);
    /**
     * 删除小区
     */
    Result deleteVillage(String villageCode);
    /**
     * 获取小区机构分页列表
     *
     * @param map
     * @param currentPage
     * @param pageSize
     * @return
     */
    Pager<OrganizationVillage> pageVillageOrg(Map<String, Object> map, int currentPage, int pageSize);
    /**
     * 获取小区分页列表
     *
     * @param map
     * @param currentPage
     * @param pageSize
     * @return
     */
    Pager<Village> pageVillages(Map<String, Object> map, int currentPage, int pageSize);

    Pager<VillageForPeopleManage> pageVillagesForPeopleManage(Map<String, Object> map, int currentPage, int pageSize);

    /**
     * 获取小区实体
     *
     * @param villageCode
     * @return Village
     */
    Village getVillage(String villageCode);

    Result addBuilding(Building build);

    Result updateBuild(Building build);

    Result deleteBuild(String id);


    /*=========================小区出入口=============================*/
    /**
     * 获取小区出入口分页列表
     *
     * @param map
     * @param currentPage
     * @param pageSize
     * @return
     */
    Pager<VillageEntranceExit> pageVillageEntranceExits(Map<String, Object> map, int currentPage, int pageSize);
    /**
     * 新增小区出入口
     * @return
     * @throws SQLException
     */
    Result insertVillageEntranceExit(VillageEntranceExit villageEntranceExit);
    /**
     * 编辑小区出入口
     * @param villageEntranceExit
     * @return
     * @throws SQLException
     */
    Result updateVillageEntranceExit(VillageEntranceExit villageEntranceExit);
    /**
     * 删除小区出入口
     * @param id 主键id
     * @return
     * @throws SQLException
     */
    Result deleteVillageEntranceExit(String id);



    /**
     * @Description: 根据父ID获取小区列表
     * @param: parentId,villageName,villageCode
     * @return:  List<Village>
     * @author: minsheng
     * @date: 2019/1/14 16:40
     */
    Pager<Village> pageVillageByParentId(Map<String, String> map ,int pageNumber,int pageSize);

    /**
     * @Description: 根据orgId获取小区信息
     * @param: map
     * @return: List<Village>
     * @author: minsheng
     * @date: 2019/1/16 18:32
     */
    List<Village> listVillagesByOrgId(Map<String, Object> map);


    /**
     * 查询小区
     * @return
     */
    List<SysVillage> queryAllVillage();


    /**
     * 获取小区行政区划树（包含小区）
     * @param param
     * @return
     */
    List<OrganizationVillage> listVillageTree(Map<String, Object> param);

    /**
     * 根据小区编号获取所有的楼栋
     * @param villageCode
     * @return
     */
    List<String> getBuildNosByVillageCode(String villageCode);
    Map<String,Building> getBuildMapByVillageCode(String villageCode);

    List<String> getHouseNosByVillageCode(String villageCode,List<String> buildNos);

    int queryVillagePeopleManageInfo(String villageCode);

    Set<String> getOrgIdsByVillageCode(String villageCode);

    /**
     * 获取所有子行政区划id
     * @param parentId
     * @return
     */
    String getAllChildOrgId(String parentId);

    Integer getAllVillageCounts();

    /**
     * 通过小区编号和楼栋编号获取楼栋单元信息
     *
     * @param search
     * @return
     */
    Pager<Unit> pageUnits(UnitSearch search);

    /**
     * 通过小区编号查找所有的房屋信息
     * @param villageCode
     * @return
     */
	Map<String, Map<String, List<String>>> getAllHousesByVillageCode(String villageCode);

    public List<Tree> villageTree(TreeSearchModel model);

    List<StatisticsVillageDataResp> getStatisticsVillageList(Map<String, Object> map);
}
